﻿using BW.MesProject.Public.ErrorCode;
using BW.MesProject.WareHouse.Application;
using BW.MesProject.WareHouse.Domain;
using BW.MesProject.WareHouse.Infrastructure;
using BW.MesProject.WareHouse.Infrastructure.Dto.Input;
using BW.MesProject.WareHouse.Infrastructure.Dto.OutPut;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace BW.MesProject.WareHouse.Host.Controllers
{
    /// <summary>
    /// 库位
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class LocationController : ControllerBase
    {
        // GET: api/<LocationController>
        private readonly ILocationServices locationServices;

        public LocationController(ILocationServices locationServices)
        {
            this.locationServices = locationServices;
        }
        /// <summary>
        /// 添加库位
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public ApiResult<int> AddLocation(LocationModel model)
        {
            return locationServices.AddLocation(model);
        }
        /// <summary>
        /// 删除库位
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpDelete]
        public ApiResult<int> DeleteLocation(long Id)
        {
            return locationServices.DeleteLocation(Id);
        }
        /// <summary>
        /// 获取库位
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public ApiResult<List<LocationOut>> GetLocation([FromQuery] QryInput qryInput)
        {
            return locationServices.GetLocation(qryInput);
        }
        /// <summary>
        /// 修改库位
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public ApiResult<int> UpdatLocation(LocationModel model)
        {
            return locationServices.UpdateLocation(model);
        }
        /// <summary>
        /// 修改启用
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpPut]
        public ApiResult<int> UpdateEnable(LocationModel model)
        {
            return locationServices.UpdateEnable(model);
        }

        /// <summary>
        /// 软删除
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpDelete]
        public ApiResult<int> UpdateDelete(long Id)
        {
            return locationServices.UpdateDelete(Id);
        }

        /// <summary>
        /// 查询编码
        /// </summary>
        /// <param name="LocationID"></param>
        /// <returns></returns>
        [HttpGet]
        public ApiResult<int> GetLocationID(string LocationID)
        {
            return locationServices.GetLocationID(LocationID);
        }

    }
}
